<template>
    <div>

        <template>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column type="expand">
                    <template slot-scope="props">
                        <el-form label-position="left" inline class="demo-table-expand">
                            <el-form-item label="题干">
                                <span>{{ props.row.title }}</span>
                            </el-form-item>
                            <el-form-item label="选项A.">
                                <span>{{ props.row.sa }}</span>
                            </el-form-item>
                            <el-form-item label="选项B.">
                                <span>{{ props.row.sb }}</span>
                            </el-form-item>
                            <el-form-item label="选项C.">
                                <span>{{ props.row.sc }}</span>
                            </el-form-item>
                            <el-form-item label="选项D.">
                                <span>{{ props.row.sd }}</span>
                            </el-form-item>
                            <el-form-item label="正确答案">
                                <span>{{ props.row.sw }}</span>
                            </el-form-item>
                            <el-form-item label="知识点">
                                <span>{{ props.row.kown }}</span>
                            </el-form-item>
                            <el-form-item label="难易程度">
                                <span>{{ props.row.degree }}</span>
                            </el-form-item>
                        </el-form>
                    </template>
                </el-table-column>
                <el-table-column label="题目 ID" prop="qid">
                </el-table-column>
                <el-table-column label="题干" prop="title">
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除
                        </el-button>
                    </template>


                </el-table-column>
            </el-table>
        </template>

    </div>
</template>

<script>
export default {
    data() {
        return {
            personques: {
                qid: 1,
                userid: 123123
            },
            tableData: [{
                qid: null,
                title: "null",
                sa: "null",
                sb: "null",
                sc: "null",
                sd: "null",
                sw: "null",
                konw: "null",
                Degree: "null"
            }]

        }
    },
    created() {
        this.pushalldata()
    },
    methods: {
        open1() {
                this.$message({
                    message: '操作成功!',
                    type: 'success'
                });
            },
            open2() {
                this.$message({
                    message: '操作失败'
                });
            },
        handleDelete(index, row) {
            console.log(row);
           
            var that = this
            this.personques.qid = row.qid
            this.$axios.post('/personques/delete', {

                userid: that.personques.userid,
                qid: that.personques.qid

            }).then(function (response) {
                console.log(response);

                that.open1();
                that.pushalldata()

            })
                .catch(function (error) {
                    console.log(error);
                    that.open2();
                });


        },
        pushalldata() {
            var that = this
            this.$axios.get('/personques/getsome', {
                params: {
                    userid: that.personques.userid
                }
            }).then(function (response) {
                console.log(response);


                that.tableData = response.data.data

            })
                .catch(function (error) {
                    console.log(error);
                    that.open2();
                });
        }
    }
}
</script>

<style >
.demo-table-expand {
    font-size: 0;
}

.demo-table-expand label {
    width: 90px;
    color: #99a9bf;
}

.demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
}
</style>